package com.dg11185.nearshop.net.response;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.dg11185.nearshop.net.entity.Industry;

public class GetIndustryListResponse {

    public NetStatus status = null;
    
    public List<Industry> industries = null;

    public GetIndustryListResponse() {
        industries = new ArrayList<Industry>();
    }

    public void parseJson(String response) {
        try {
            JSONObject jsonObject = new JSONObject(response);
            status = NetStatus.getStatus(jsonObject.optString("status"));
           
            if(!jsonObject.isNull("industryList")){
                JSONArray industryArray = jsonObject.optJSONArray("industryList");
                for (int a = 0; a < industryArray.length(); a++) {
                    Industry industry = new Industry();
                    industry.parseEntity(industryArray.getJSONObject(a));
                    industries.add(industry);
                }
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}
